package com.project.bean;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;

/**
 * @author lyl
 * description:用户实体bean
 */
public class UserBean {
    /**
     * 用户id
     */
    private int userId;

    /**
     * 用户名称
     */
    @Pattern(regexp = "[\\w]{2,}", message = "用户名格式错误")
    private String username;

    /**
     * 用户性别
     */
    @Pattern(regexp = "[男|女]", message = "男女不分？")
    private String sex;

    /**
     * 用户工资
     */
    @Min(value = 1000, message = "太少了")
    @Max(value = 99999, message = "太多了")
    private Integer money;

    /**
     * 用户生日
     */
    @Past(message = "无法识别的生日")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    public UserBean() {
    }

    public UserBean(String username, String sex, int money, LocalDate birthday) {
        this.username = username;
        this.sex = sex;
        this.money = money;
        this.birthday = birthday;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", sex='" + sex + '\'' +
                ", money=" + money +
                ", localDate=" + birthday +
                '}' + "\n";
    }
}
